<template>
  <div class="app-container" :style="height">
    <h2 style="text-align:center">{{form.contentTitle}}</h2>
    <div class="box">
      <span>●类型：{{form.typeName}}</span>
      <span>●状态：{{form.statusName}}</span>
      <span>●发布时间：{{form.issueTime}}</span>
      <span v-show="form.contentSource!=''">●来源：{{form.contentSource}}</span>
      <br>
      <span v-show="form.contentAuthor!=''">●作者：{{form.contentAuthor}}</span>
      <span v-show="form.contentEditor!=''">●编辑：{{form.contentEditor}}</span>
      <span>●发布部门：{{form.issueDepartmentName}}</span>
      <span>●发布人：{{form.issueUserName}}</span>
      <span style="width: 100%;white-space: normal;" >●接收部门：{{form.receiveDepartmentName==null?"所有人":form.receiveDepartmentName}}</span>
      <span style="width: 100%;white-space: normal;" >●接收人：{{form.receiveUserName==null?"所有部门":form.receiveUserName}}</span>
    </div>
    <el-divider></el-divider>
    <div style="font-size: 1.1rem;line-height: 1.5;color: #303133;padding: 20px 50px 0px 50px;" v-html="form.contentContent" class="ql-editor">
    </div>
    <div style="font-size: 1.1rem;line-height: 1.5;color: #303133;padding: 20px 50px 0px 50px;" v-show="form.attachmentName!=null">
      附件<br>
      <el-link v-for="url in attachment" :href=url.url target="_blank" :underline="false"
               style="display:block;margin: 5px 0 0 20px;padding: 5px 0;width: 300px;border:1px solid #5a5e66;text-align: center;border-radius: 10px">{{url.name}}</el-link>
    </div>
  </div>
</template>

<style>
  .box{
    font-size: 0.9rem;
    line-height: 1.5;
    color: #606c71;
    text-align:left;
  }

  .box span{
    padding:5px 50px 0px 50px;
    display: inline-block;
    text-align: left;
    width: 25%;
    white-space: nowrap;
  }
</style>

<script>
  import { getContent } from "@/api/system/content";

  export default {
    name: "contentData",
    data() {
      return {
        height:"max-height:"+((document.documentElement.clientHeight||document.body.clientHeight)-110)+"px;overflow-y:auto",

        form: {},
        attachment : [],
      }
    },
    created() {
      const contentId = this.$route.params && this.$route.params.contentId;
      this.getList(contentId);
    },
    methods: {
      getList(contentId) {
        getContent(contentId).then(response => {
          this.form = response.data;

          const arr = [];
          if (response.data.attachmentName!=null){
            var attachmentName = response.data.attachmentName.split(",");
            var attachmentUrl = response.data.attachmentUrl.split(",");
            for (var k=0;k<attachmentName.length;k++){
              arr.push({
                name:attachmentName[k],
                url:attachmentUrl[k]
              });
            }
          }
          this.attachment = arr;
        });
      },
    }
  }
</script>
